<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>
        审批配置
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../../../css/main.css" media="all">
    <script type="text/javascript" src="../../../../lib/loading/okLoading.js"></script>
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="../../../../lib/layui/css/layui_2.5.7.css">

</head>
<!--借还流水-->
<style>
    .layui-form-label {
        width: 150px !important;
    }

    .formtype{
        margin-top: 20px;
        margin-bottom: 20px;
    }

    .onetype{
        margin-left: 3%;
    }

    .latype{
        margin-left: 10%;
    }
</style>

<body>
<div class="x-nav">
        <span class="layui-breadcrumb">
            <a><cite>首页</cite></a>
            <a><cite>申请/报价单</cite></a>
            <a><cite>审批配置</cite></a>
        </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon"
                                                                        style="line-height:30px">ဂ</i></a>
</div>
<div class="main_box">
    <div class="panel-heading">
        <ul class="nav nav-tabs" id="navTabs">
            <li class="active"><a class="receivePane" data-tab="" href="config.html">审批配置</a></li>
        </ul>
    </div>
</div>
<div class="x-body" id="app">
    <form class="layui-form layui-form-pane" id="add">
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">

                <h5><b>报价单配置</b></h5>
                <input  autocomplete="off"  type="hidden" name="quot" id="quot" v-model="configData.quotationApprId">
                <div class="layui-form-item formtype">
                    <label class="layui-form-label onetype">报价单审批人</label>
                    <div style="width: 30%"  class="layui-input-inline">
                        <input  autocomplete="off"  type="text" name="quotationApprover" v-model="configData.quotationApprover" placeholder="报价单审批人" class="layui-input" readonly>
                    </div>
                    <label class="layui-form-label latype">重新配置报价单审批人</label>
                    <div style="width: 32%" class="layui-input-inline">
                        <select id="quotationUserId" name="quotationUserId"  lay-search="">
<!--                            <option value="">选择报价单审批人</option>-->
                        </select>
                    </div>
                </div>

                <h5><b>申请单配置</b></h5>
                <input  autocomplete="off"  type="hidden" name="requ" id="requ" v-model="configData.requestFormApprId">
                <div class="layui-form-item formtype">
                    <label class="layui-form-label onetype">申请单审批人</label>
                    <div style="width: 30%"  class="layui-input-inline">
                        <input  autocomplete="off"  type="text" name="requestFormApprover" v-model="configData.requestFormApprover" placeholder="申请单审批人" class="layui-input" readonly>
                    </div>
                    <label class="layui-form-label latype">重新配置申请单审批人</label>
                    <div style="width: 32%" class="layui-input-inline">
                        <select id="requestformUserId" name="requestformUserId" lay-search="">
<!--                            <option value="">选择申请单审批人</option>-->
                        </select>
                    </div>
                </div>


                <div style="text-align: center;margin-left: -5%;margin-top: 50px;" class="layui-form-item">
                    <button class="layui-btn" type="button" lay-filter="sub" lay-submit="sub">
                        保存
                    </button>
                </div>
                <div style="height:20px;"></div>
            </div>
        </div>
    </form>
</div>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="../../../../js/myAjax.js"></script>
<script type="text/javascript" src="../../../../js/pub.js"></script>
<script src="../../../../lib/layui/layui2.5.7.js" charset="utf-8"></script>
<script src="../../../../js/x-layui.js" charset="utf-8"></script>
<script src="../../../../js/vue.min.js" charset="utf-8"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>

<script>
    layui.use(['element', 'layer', 'form', 'laydate'], function () {
        $ = layui.jquery;//jquery
        lement = layui.element();//面包导航
        layer = layui.layer;//弹出层
        laydate = layui.laydate;//日期插件
        form = layui.form;
        okLoading.close($);
    })
</script>
<script>

    var vm = new Vue({
        el: "#app",
        data: {
            configData: null,
        },
        mounted() {
            let request = {
                url: 'kf/config/getKfConfig',
                data: {
                    userId: $userId
                },
                method: "GET",
            };
            sendRequest(request, (res) => {
                this.configData = res.data
            });
        },
        methods: {}

    });

    layui.use(['laydate', 'form', 'layer'],
        function () {
            var form = layui.form;
            var layer = layui.layer;

            //监听审批提交
            form.on('submit(sub)',
                function (data) {
                    let form = data.field;
                    form.userId = $userId;
                    let request = {
                        url: 'kf/config/editKfConfig',
                        data: form,
                        method: "GET",
                    };

                    console.log(request);
                    sendRequest(request, (data) => {
                        console.log(data);
                        if (data.code === 0) {
                            layer.alert("操作成功", {
                                    icon: 6
                                },
                                function () {
                                   window.location.reload()
                                });
                        } else {
                            layer.alert(data.msg, {
                                icon: 5
                            })
                        }
                    });
                    return false;
                });
        });

    setTimeout(() => {
        let form = layui.form;
        let request = {
            url: 'user/findUserSelect',
            data: {
                userId: $userId,
            },
            method: "get",
        };
        sendRequest(request, (res) => {
            let d = res.data;
            let q = document.getElementById("quot").value
            let r = document.getElementById("requ").value
            console.log("q=" + q);
            console.log("r=" + r);
            $.each(d, function (index, item) {
                let opt;
                if(item.id == q){
                    opt = $("<option value=" + item.id + " selected>" + item.nickname + "</option>");
                }else{
                    opt = $("<option value=" + item.id + ">" + item.nickname + "</option>");
                }
                $("select[name=quotationUserId]").append(opt);
            });
            $.each(d, function (index, item) {
                let opt;
                if(item.id == r){
                    opt = $("<option value=" + item.id + " selected>" + item.nickname + "</option>");
                }else{
                    opt = $("<option value=" + item.id + ">" + item.nickname + "</option>");
                }
                $("select[name=requestformUserId]").append(opt);
            });
            form.render('select');
        });

    }, 300)

</script>

</body>

</html>
